package com.example.demo.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA 2023.
 * Description:
 * User: homechen
 * Date: 2024-03-11
 * Time: 22:41
 */
@Configuration
public class AppCofig implements WebMvcConfigurer {
    // 注入普通的拦截器
    @Autowired
    private LoginInterceptor loginInterceptor;

    // 如果 拦截器为 false，就继续拦截，true 就放行
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 实现拦截规则  自行定义
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns() // 拦截
                .excludePathPatterns(); // 放行
    }
}
